﻿(function ($) {
    $(function () {
        //zry.util.appPath + "api/AppFun/GetReChargeData";
        zry.common.ajaxpost(zry.mng.url.GetReChargeData, null, function (d) {
            if (d.suc) {
                $('#moneyscript').tmpl(d.data).appendTo("#moneys");
                bindRecharge();
            }
        });
    });
    
    function bindRecharge() {
        $(".money").click(function () {
            var obj = this;
            var root = zry.util.siteUrl();
            $("#notify_url").val(root + "/Manage/PayNotice/Index");
            $("#total_fee").val($(obj).find(".price").text());
            $("#body").val($(obj).find(".moneys").text());

            var data = {};
            data.OrderType = 1;
            data.Money = $(obj).find(".price").text();
            //zry.mng.url.GenOrder = zry.util.appPath + "api/Order/GenOrder";
            zry.common.ajaxpost(zry.mng.url.GenOrder, data, function (d) {
                if (d.suc) {
                    debugger;
                    var orderno = d.data.OrderNo;

                    var myDate = new Date();
                    var myYear = myDate.getYear();
                    var myMonth = myDate.getMonth();
                    var myHour = myDate.getHours();
                    var myMinute = myDate.getMinutes();
                    var mySecond = myDate.getSeconds();

                    $("#out_trade_no").val(orderno);
                    var column = {};
                    column.service = $("#service").val();
                    column.partner = $("#partner").val();
                    column.out_trade_no = $("#out_trade_no").val();
                    column.subject = $("#subject").val();
                    column.body = $("#body").val();
                    column.payment_type = "1";
                    column.total_fee = $("#total_fee").val();
                    column.seller_id = column.partner
                    column.input_charset = $("#_input_charset").val();
                    column.notify_url = $("#notify_url").val();
                    //zry.mng.url.GetSign = zry.util.appPath + "api/AppFun/GetSign";
                    zry.common.ajaxpost(zry.mng.url.GetSign, column, function (d) {
                        if (d.suc) {
                            debugger;
                            $("#sign").val(d.data);
                            document.forms['alipaysubmit'].submit();
                        }
                    });
                }
            });
        });
    }

})(jQuery)